package com.cy.pj.common.web;

import com.cy.pj.common.pojo.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//@RestControllerAdvice
//@Slf4j
//public class GlobalExceptionHandler {
//
//    @ExceptionHandler
//    public JsonResult doHandleRuntimeException(RuntimeException e){
//        log.error("exception {}",e.getMessage());
//        e.printStackTrace();
//        return new JsonResult();
//    }
//}
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(RuntimeException.class)
    public JsonResult doHandleRuntimeException(RuntimeException e){
        log.error("exception {}",e.getMessage());
        e.printStackTrace();
        return new JsonResult(e);
    }
}